package com.jinhua.usercenter.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public Result businessExceptionHandler(BusinessException e){
        log.error("businessException" + e.getMessage(), e);
        return ResultUtils.error(e.getCode(),e.getMessage());
    }
    @ExceptionHandler
    public Result runtimeExceptionHandler(Exception e){
        log.error("runtimeException" , e);
        return  ResultUtils.error(ErrorCode.SYSTEM_ERROR);
    }
}
